<template>
  <h1>猜数字练习</h1>
  <input type="text" placeholder="请猜一个1-100的数字" v-model="num">
  <button @click="guess">点击验证</button>
  <h3>小提示：{{tip}}</h3>
</template>

<script setup>
import {ref} from "vue";

const num = ref('');
const tip = ref('');
let g = parseInt(Math.random()*100+1);
console.log(g);

const guess = ()=>{
  if (num.value > g){
    tip.value = '猜大了';
  }else if (num.value < g){
    tip.value = '猜小了';
  }else {
    tip.value = '恭喜你猜对了！';
  }
}
</script>

<style scoped>

</style>